home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20010306-20010921 / 000032_news@columbia.edu _Sat Mar 17 12:21:32 2001.msg < prev    next >
Internet Message Format  |  2020-01-01  |  4KB

  1. Return-Path: <news@columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  3.     by fozimane.cc.columbia.edu (8.9.3/8.9.3) with ESMTP id MAA10750
  4.     for <kermit.misc@cpunix.cc.columbia.edu>; Sat, 17 Mar 2001 12:21:32 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.9.3/8.9.3) id MAA11425
  7.     for kermit.misc@watsun.cc.columbia.edu; Sat, 17 Mar 2001 12:07:42 -0500 (EST)
  8. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  9. From: fdc@columbia.edu (Frank da Cruz)
  10. Subject: Re: need passive mode ftp command line client
  11. Date: 17 Mar 2001 17:07:42 GMT
  12. Organization: Columbia University
  13. Message-ID: <9905ku$b4u$1@newsmaster.cc.columbia.edu>
  14. To: kermit.misc@columbia.edu
  15.  
  16. In article <slrn9b5n4p.mt.grante@tuxtop.visi.com>,
  17. Grant Edwards <grante@visi.com> wrote:
  18. : On Fri, 16 Mar 2001 16:30:58 -0800, Anthony Ewell <aewell@gbis.com> wrote:
  19. : >        I need to write a script that will do a directory
  20. : >of an ftp site.  Then,  depending on what I find in the
  21. : >directory, do a download in passive mode.   (Passive
  22. : >mode is required to get by my firewall.)
  23. : >
  24. : >        Does any one of a command line mode ftp client that
  25. : >I can give a list of commands to that will also use
  26. : >passive mode to transfer file?
  27. : I believe that ncftp will do passive.  
  28. : Also take a look at ckermit.  It supports ftp file transfer and
  29. : has a very sophisticated scripting language akin to "expect".
  30. C-Kermit 7.1 is the one that has this:
  31.  
  32.   http://www.columbia.edu/kermit/ck71.html
  33.  
  34. More about its ftp client here:
  35.  
  36.   http://www.columbia.edu/kermit/ftpclient.html
  37.  
  38. And a tutorial is here:
  39.  
  40.   http://www.columbia.edu/kermit/ftpscript.html
  41.  
  42. And complete documentation here:
  43.  
  44.   http://www.columbia.edu/kermit/ckermit3.html#ftp
  45.  
  46. About getting a directory and looking at it...  There are two ways to do
  47. this.  You can use:
  48.  
  49.   C-Kermit> ftp directory [ filespec ] > filename
  50.  
  51. and then read the file with FOPEN, FREAD, etc, parsing the lines, which
  52. are in whatever format the server feels like sending them.  If the server
  53. is UNIX, the directory lines are probably like this; note that the filename
  54. starts in column 55 (1-based):
  55.  
  56. -rw-rw----  1 fdc      staff       14169 Mar 14 11:23 foo
  57. -rw-rw----  1 fdc      staff       28010 Mar 16 12:05 h
  58. -rw-r--r--  1 fdc      staff       19294 Mar 16 12:06 j.jpg
  59. -rw-rw----  1 fdc      staff       46949 Mar 16 15:35 kt
  60. -rw-rw----  1 fdc      staff         489 Mar 13 10:37 r
  61. -rw-rw----  1 fdc      staff        3374 Mar 13 10:36 r.~1~
  62.  
  63. Let's say you've stored the directory listing in a file called dirlist
  64.  
  65.   fopen \%c dirlist       ; Open dirlist and assign channel number to \%c
  66.   if fail exit 1 Can't open directory list file
  67.   .\%n = 0
  68.   while true {
  69.       fread \%c line      ; Read a line into variable named 'line'
  70.       if fail break       ; EOF     
  71.       .fn := \s(line[55]) ; Extract substring from col 55 to end
  72.       echo [\m(fn)]       ; Echo the filename with brackets around it
  73.       increment \%n       ; Count it
  74.   }
  75.   fclose \%c              ; Done - close file
  76.   echo Files: \%n         ; Tell how many filenames
  77.  
  78. Once you have isolated the filename (fn) you can do whatever you want
  79. with it -- compare it with a pattern, a list, etc.  Then to download in
  80. passive mode, simply:
  81.  
  82.   set ftp passive
  83.   get \m(fn)
  84.   if fail exit 1 GET \m(fn) failed.
  85.  
  86. C-Kermit 7.1 is currently in prerelease testing, so this is a good time
  87. to try it and send in any comments or suggestions about the scriptable
  88. FTP client.  In fact, your problem suggests one improvement already, which
  89. is to make the NLST result available to the program directly, so you don't
  90. have to parse arbitrary directory-listing formats.
  91.  
  92. - Frank